/*
 * ---------------------------------------------------------------------------------------------------------------------------------------------------*
 * SBS Priceboard V2.0
 * Copyright (C) 2008 Unicom Vietnam JSC
 * ---------------------------------------------------------------------------------------------------------------------------------------------------* 
 * HeadURL: http://192.168.1.4/svn/priceboard/trunk/SBS_PriceboardV2/front-end/end-user/ipriceboard/src/com/unicom/priceboard/thread/TimerThread.java
 * LastChangeBy: quanhm
 * LastChangeDate: Aug 6 2008
 */
package com.unicom.priceboard.thread;

import java.util.Calendar;

/**
 * Creation date : 2007-12-27
 * @author quan
 * This thread acts like an internal timer
 */
public class TimerThread implements Runnable {

	public volatile static int CURRENT_HOUR_OF_DAY; // value from 1 to 24
	public volatile static int CURRENT_MINUTE; //value from 0 to 59
	public volatile static int CURRENT_DAY_OF_WEEK; //1:Sunday,.....,7:Saturday
	public volatile static String CURRENT_DATE;
	public volatile static int CURRENT_TIME;//900->9AM,1000->10AM,1030->10:30AM...
	public volatile static int SECONDS;
	
	
	
	public void run() {
		while(true)	{
			Calendar cal = Calendar.getInstance();
			CURRENT_HOUR_OF_DAY = cal.get(Calendar.HOUR_OF_DAY);
			CURRENT_MINUTE = cal.get(Calendar.MINUTE);
			CURRENT_DAY_OF_WEEK = cal.get(Calendar.DAY_OF_WEEK);
			CURRENT_TIME = (CURRENT_HOUR_OF_DAY*100)+CURRENT_MINUTE;
			SECONDS = cal.get(Calendar.SECOND);
			
			try {
				Thread.sleep(1000);
			} catch (Exception e) {
				System.out.println("Cannot make timer sleep");
			}
		}
	}
	
}
